﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using CrystalDecisions.Windows;

namespace QLThuoc_report
{
    public partial class ThuocQH : Form
    {
        public ThuocQH()
        {
            InitializeComponent();
        }

        private void ThuocQH_Load(object sender, EventArgs e)
        {
           SqlConnection conn = new SqlConnection("Data Source =(local);Initial Catalog=QLThuoc;Integrated Security=true");
            SqlDataAdapter da = new SqlDataAdapter("SELECT     MaThuoc AS 'Mã Thuốc', TenThuoc AS 'Tên Thuốc', SoLuongTon AS 'Số Lượng Tồn', XuatXu AS 'Xuất Xứ', HanDung AS 'Hạn Dùng', GiaTien AS 'Giá Tiền', DATEDIFF(dd,  HanDung, GETDATE()) AS 'Quá Hạn' FROM         dbo.tbl_Thuoc WHERE     (DATEDIFF(dd, HanDung, GETDATE()) > 0)", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            //lay duong dan du chuy?n sang máy tính nào c?ng ko b? l?i, ko có c?ng ðc nhýng sang máy tính khác s? ko ch?y ðc
            string path = Application.StartupPath;
            path = path.Substring(0, path.LastIndexOf("bin")) + "CrystalReport1.rpt";
            ThuocQuaHan report = new ThuocQuaHan();
            report.SetDataSource(dt);
            crystalReportViewer1.ReportSource = report;
        }
    }
}
